<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">


    <body>

        <ui:composition template="./WEB-INF/template/simple/simpleTemplate.xhtml">

            <ui:define name="title">Meteocal Homepage</ui:define>
            
            <ui:define name="content">
                <!--If the user is already logged in redirect to user/index -->
                <f:event type="preRenderView" listener="#{guestHome.checkIfLogged()}" />
                
                <h:form class="centeredForm" id="loginForm">

                        <p:panelGrid columns="2" >
                            <f:facet name="header">
                                Login                           
                            </f:facet>
                            
                            <p:outputLabel for="username" value="Email"/>
                            <p:inputText id="username" value="#{guestHome.email}" 
                                         required="true" />
                            <p:outputLabel for="pass" value="Password"/>
                            <p:password id="pass" value="#{guestHome.password}" 
                                        required="true" />
                            <f:facet name="footer">
                                <p:commandButton styleClass="onRightBtn" action="#{guestHome.submitLogin}" value="Login" ajax="true" update="@all" />
                            </f:facet>
                        </p:panelGrid>
                        <p:fieldset>
                            
                            <p:link outcome="register" value="Signup" styleClass="login-auxiliary-text"/>

                        </p:fieldset>

                    </h:form>
            </ui:define>

            <ui:define name="header">
                <ui:include src="WEB-INF/template/pageFragments/indexHeader.xhtml" />
            </ui:define>
        </ui:composition>

    </body>
</html>
